﻿namespace Mockingbird.Core.Infrastructure.Membership.Identity.Implementation
{
    using System.Security.Principal;
    using Interface;
    using Models;

    public class CustomPrincipal : ICustomPrincipal
    {
        private IIdentity identity;

        public CustomPrincipal(string username)
        {
            this.identity = new GenericIdentity(username);
        }

        public CustomPrincipal()
        {
        }

        public IIdentity Identity
        {
            get
            {
                if (identity == null)
                {
                    identity = new GenericIdentity(Properties.Email);
                }

                return identity;
            }

            private set { identity = value; }
        }

        public UserPropertiesModel Properties { get; set; }

        public bool IsInRole(string role)
        {
            return role == Properties.Email;
        }
    }
}
